import { createRouter, createWebHistory } from 'vue-router'

export const routerList = [
  {
    path: 'dashboard',
    name: 'dashboard',
    chName: '数据看板',
  },
  {
    path: 'hold',
    name: 'hold',
    chName: '持仓管理',
  },
  {
    path: 'net',
    name: 'net',
    chName: '网格管理',
  },
  {
    path: 'strategy',
    name: 'strategy',
    chName: '策略管理',
  },
  {
    path: 'category',
    name: 'category',
    chName: '分类管理',
  },
  {
    path: 'platform',
    name: 'platform',
    chName: '平台管理',
  }

]

export const routeListWithComponent = routerList.map(item => {
  const { name, path, chName } = item

  return {
    name, path, chName,
    component: () => import(`@/views/${name}/index.vue`)
  }
})
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/layout/index.vue'),
      redirect: '/dashboard',
      children: [
        ...routeListWithComponent,
        {
          path: 'net-edit',
          name: 'netEdit',
          chName: '网格管理',
          component: () => import('@/views/net/NetInfo.vue')
        },
      ]

    },
  ]
})

export default router
